use std::fs;
use std::os::unix::fs::MetadataExt;
use std::path::Path;
use std::env;
fn main() {

    let args:Vec<String> = env::args().collect();
    if args.len() != 2
    {
        println!("please input file name .");
        return;
    }
    let file_path = Path::new(&args[1]);
    if !file_path.exists()
    {
        println!("error,file is not existed.");
        return;
    }
    if let Ok(meta_data) = fs::metadata(file_path)
    {
        if let Ok(abs_path) = fs::canonicalize(file_path)
        {
            println!("file path is {}",abs_path.display());
        }
        else 
        { 
            println!("file path is {}",file_path.display());
        }
        println!("file size is {}",meta_data.len());
        println!("file perm is {:?}",meta_data.permissions());
    }
    else 
    {
        println!("read file info failed .");
    }
}
